package com.example.gybicycle.common.bigcycle;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

@Data
@Schema(name = "开锁")
public class OpenLock {
    @Schema(description = "指令内容")
    private Map content;
    @Schema(description = "设备ID")
    private String deviceId;
    @Schema(description = "操作者")
    private String operator;
    @Schema(description = "产品ID")
    private Integer productId;
    @Schema(description = "设备指令缓存时长，选填。单位：秒，取值范围：0-864000")
    private Integer ttl ;
    @Schema(description = "设备组ID，选填，当指令级别为设备级，" +
            "               deviceId不为空，deviceGroupId为空；" +
            "               当指令级别为设备组级，deviceId为空，deviceGroupId不为空。")
    private Integer deviceGroupId;
    @Schema(description = "指令级别，1或2为设备级别,3为设备组级别")
    private Integer level;

    public  OpenLock(String content,String deviceId,String operator,Integer productId,Integer ttl,
                     Integer deviceGroupId,Integer level){
//        this.content=content;
        this.deviceId=deviceId;
        this.operator= operator;
        this.productId=productId;
        this.ttl=ttl;
        this.deviceGroupId=deviceGroupId;
        this.level=level;

    }
    public OpenLock(Integer childLockId,String mainLockId,String operator,Integer productId){
        Map<String,Object> content=new HashMap<>();
        Map<String,Object> params=new HashMap<>();
        params.put("SLN",childLockId);
        content.put("params",params);
        content.put("serviceIdentifier","ULC");
        this.content=content;
        this.deviceId=productId+"86"+mainLockId;
        this.operator=operator;
        this.productId=productId;
        this.ttl=60;
        this.level=1;

    }

}
